<?php
class ProfileAction extends CommonAction {

	public function savepw()
	{
		$oldpw = I('oldpw');
		$newpw = I('newpw');
		$renewpw = I('renewpw');
		if ($renewpw == ""|| $newpw=="" || $oldpw=="") {
			$this->error('原始密码，新密码，确认密码军不能为空');
            return;
		}
		if (strlen($newpw) < 6) {
            $this->error('密码长度不能小于6位');
            return;
        }

		if ($newpw != $renewpw) {

            $this->error('新密码与确认密码不一致！！！'.$repwd);
            return;
        }

        $Member = D('Member');
        $map['id'] = $this->mid;
		$map['password'] = md5($oldpwd);
		$vo = $Member->where($map)->find();
		if (!$vo) {
			$this->error('原始密码错误。');
            return;
		}
		unset($map);
		$map['id']=$this->mid;
		$Member->where($map)->setField('password',md5($pwd));
		$this->success('密码修改成功，请记住你的新密码。');
	}
}